package com.learn.controller;


import com.learn.apis.PayFeignSentinelApi;
import com.learn.resp.Result;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author DJJ_F
 * @version 1.0
 * @date 2025/08/05
 * @description ch11 nacos 客户端83
 */
@RestController
public class OrderController {
    @Resource
    private RestTemplate restTemplate;

    @Value("${service-url.nacos-user-service}")
    private String PAY_PREFIX;

    @Resource
    private PayFeignSentinelApi payFeignSentinelApi;
//    @Resource
//    private TestFeignApi testFeignApi;

    @GetMapping("/order/get/{id}")
    public Result get(@PathVariable("id") Integer id) {
        return restTemplate.getForObject(PAY_PREFIX + "/pay/get/{id}", Result.class, id);
    }

    @GetMapping("/order/get/sentinel/{id}")
    public Result getSentinel(@PathVariable("id") Integer id) {
        return payFeignSentinelApi.getSentinel(id);
    }
}
